blob: ac10cfbb14aba460973019d712ee90e8804de34d [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-revert(1)
2=============
3
4NAME
5----
Junio C Hamano89a57342010-06-22 23:22:556git-revert - Revert some existing commits
Junio C Hamano1a4e8412005-12-27 08:17:237
8SYNOPSIS
9--------
Junio C Hamano89a57342010-06-22 23:22:5510'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
Junio C Hamano1a4e8412005-12-27 08:17:2311
12DESCRIPTION
13-----------
Junio C Hamano1a4e8412005-12-27 08:17:2314
Junio C Hamano89a57342010-06-22 23:22:5515Given one or more existing commits, revert the changes that the
16related patches introduce, and record some new commits that record
17them. This requires your working tree to be clean (no modifications
18from the HEAD commit).
19
20Note: 'git revert' is used to record some new commits to reverse the
21effect of some earlier commits (often only a faulty one). If you want to
Junio C Hamano3580ad22008-08-21 00:27:4022throw away all uncommitted changes in your working directory, you
23should see linkgit:git-reset[1], particularly the '--hard' option. If
24you want to extract specific files as they were in another commit, you
Junio C Hamano1aa40d22010-01-21 17:46:4325should see linkgit:git-checkout[1], specifically the `git checkout
26<commit> -- <filename>` syntax. Take care with these alternatives as
Junio C Hamano3580ad22008-08-21 00:27:4027both will discard uncommitted changes in your working directory.
28
Junio C Hamano1a4e8412005-12-27 08:17:2329OPTIONS
30-------
Junio C Hamano89a57342010-06-22 23:22:5531<commit>...::
32Commits to revert.
Junio C Hamano2d47c622007-01-18 06:24:1033For a more complete list of ways to spell commit names, see
Junio C Hamanoc27b7332010-10-14 04:37:2834linkgit:gitrevisions[7].
Junio C Hamano89a57342010-06-22 23:22:5535Sets of commits can also be given but no traversal is done by
36default, see linkgit:git-rev-list[1] and its '--no-walk'
37option.
Junio C Hamano1a4e8412005-12-27 08:17:2338
Junio C Hamanoeb415992008-06-08 22:49:4739-e::
40--edit::
Junio C Hamano1aa40d22010-01-21 17:46:4341With this option, 'git revert' will let you edit the commit
Junio C Hamano0e661132008-01-21 02:37:4442message prior to committing the revert. This is the default if
Junio C Hamano1a4e8412005-12-27 08:17:2343you run the command from a terminal.
44
Junio C Hamanoeb415992008-06-08 22:49:4745-m parent-number::
46--mainline parent-number::
Junio C Hamanod814b6d2007-11-04 11:13:4947Usually you cannot revert a merge because you do not know which
48side of the merge should be considered the mainline. This
49option specifies the parent number (starting from 1) of
50the mainline and allows revert to reverse the change
51relative to the specified parent.
Junio C Hamanof1231492008-12-22 08:27:2152+
53Reverting a merge commit declares that you will never want the tree changes
54brought in by the merge. As a result, later merges will only bring in tree
55changes introduced by commits that are not ancestors of the previously
56reverted merge. This may or may not be what you want.
57+
58See the link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for
59more details.
Junio C Hamanod814b6d2007-11-04 11:13:4960
Junio C Hamano1a4e8412005-12-27 08:17:2361--no-edit::
Junio C Hamano1aa40d22010-01-21 17:46:4362With this option, 'git revert' will not start the commit
Junio C Hamano1a4e8412005-12-27 08:17:2363message editor.
64
Junio C Hamanoeb415992008-06-08 22:49:4765-n::
66--no-commit::
Junio C Hamano89a57342010-06-22 23:22:5567Usually the command automatically creates some commits with
68commit log messages stating which commits were
69reverted. This flag applies the changes necessary
70to revert the named commits to your working tree
71and the index, but does not make the commits. In addition,
Junio C Hamanof69a0a02008-07-17 08:08:4772when this option is used, your index does not have to match
73the HEAD commit. The revert is done against the
74beginning state of your index.
Junio C Hamano1a4e8412005-12-27 08:17:2375+
76This is useful when reverting more than one commits'
Junio C Hamanof69a0a02008-07-17 08:08:4777effect to your index in a row.
Junio C Hamano1a4e8412005-12-27 08:17:2378
Junio C Hamanoeb415992008-06-08 22:49:4779-s::
80--signoff::
Junio C Hamano6d76d612008-05-09 05:46:0881Add Signed-off-by line at the end of the commit message.
82
Junio C Hamano23e3f532011-02-10 02:05:2983--strategy=<strategy>::
84Use the given merge strategy. Should only be used once.
85See the MERGE STRATEGIES section in linkgit:git-merge[1]
86for details.
87
88-X<option>::
89--strategy-option=<option>::
90Pass the merge strategy-specific option through to the
91merge strategy. See linkgit:git-merge[1] for details.
92
Junio C Hamano89a57342010-06-22 23:22:5593EXAMPLES
94--------
95git revert HEAD~3::
96
97Revert the changes specified by the fourth last commit in HEAD
98and create a new commit with the reverted changes.
99
Junio C Hamanod3dc6492010-12-03 00:43:12100git revert -n master{tilde}5..master{tilde}2::
Junio C Hamano89a57342010-06-22 23:22:55101
102Revert the changes done by commits from the fifth last commit
103in master (included) to the third last commit in master
104(included), but do not create any commit with the reverted
105changes. The revert only modifies the working tree and the
106index.
Junio C Hamano1a4e8412005-12-27 08:17:23107
Junio C Hamano89a57342010-06-22 23:22:55108SEE ALSO
109--------
110linkgit:git-cherry-pick[1]
111
Junio C Hamano1a4e8412005-12-27 08:17:23112GIT
113---
Junio C Hamanof7c042d2008-06-06 22:50:53114Part of the linkgit:git[1] suite